/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sgt.supermarket.hibernatedao;

import java.util.Date;
import java.util.List;
import sgt.supermarket.entity.SaleProgram;
import org.hibernate.Session;
import org.hibernate.criterion.Expression;

/**
 *
 * @author Ms.MIAYU
 */
public class HibernateSaleProgramDAO extends HibernateGenericDAO<SaleProgram, Long> {

    public HibernateSaleProgramDAO(Session session) {
        super(session);
    }

    public List<SaleProgram> getByDateAndMinimumInvoiceTotal(Date date, double minimumInvoiceTotal) {
        return getSession().createCriteria(SaleProgram.class).add(
                Expression.and(
                Expression.le("startDate", date),
                Expression.ge("endDate", date))).add(Expression.le(
                "minimumInvoiceTotal", minimumInvoiceTotal)).list();
    }
}
